package com.itheima.tlias84.controller;

import com.itheima.tlias84.service.ReportService;
import com.itheima.tlias84.service.vo.JobDataVO;
import com.itheima.tlias84.service.vo.ReportVO;
import com.itheima.tlias84.service.vo.StuCountVO;
import com.itheima.tlias84.utils.ResultUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Resource
    ReportService reportService;

    @GetMapping("/empGenderData")
    public ResultUtil getEmpGenderData() {
        List<ReportVO> list = reportService.getEmpGenderData();
        if (list != null) {
            return ResultUtil.success(list);
        } else {
            return ResultUtil.failure();
        }
    }

    @GetMapping("/empJobData")
    public ResultUtil getEmpJobData() {
        JobDataVO data = reportService.getEmpJobData();
        if (data != null) {
            return ResultUtil.success(data);
        } else {
            return ResultUtil.failure();
        }
    }

    @GetMapping("/studentDegreeData")
    public ResultUtil getStuDegreeData() {
        List<ReportVO> list = reportService.getStuDegreeData();
        if (list != null) {
            return ResultUtil.success(list);
        } else
            return ResultUtil.failure();
    }

    @GetMapping("/studentCountData")
    public ResultUtil getStuCountData() {
        StuCountVO data = reportService.getStuCountData();
        if (data != null) {
            return ResultUtil.success(data);
        } else {
            return ResultUtil.failure();
        }
    }
}
